from flask  import Flask,views,render_template,request


app = Flask(__name__)
app.config.update({
    'DEBUG': True,
    'TEMPLATES_AUTO_RELOAD': True
})


@app.route('/')
def Index():
    if request.method == 'GET':
        return '基于调度方法的类视图'
    else:
        pass

class LoginView(views.MethodView):
    def __render(self,error=None):
        return  render_template('login.html',error=error)
        
    def get(self):
        return self.__render()

    def post(self):
        username = request.form.get('username')
        password = request.form.get('password')
        if username == 'Jacky' and password == 'wer12345':
            return '登录成功'
        else:
            return self.__render(error='用户名或密码错误')

app.add_url_rule('/login/',view_func=LoginView.as_view('login'))


if __name__ == "__main__":
    app.run(debug=True)